package com.example.bootintegration.util;

import lombok.Data;
import org.springframework.core.env.Environment;

/**
 * @author Quintoy
 * @date 12/30/22
 */
@Data
public class PrefixedPropertyResolver {
    private Environment environment;
    private String prefix;

    public PrefixedPropertyResolver(Environment environment, String prefix) {
        this.environment = environment;
        this.prefix = prefix;
    }

    public String getProperty(String key) {
        return environment.getProperty(prefix + key);
    }

    public String getProperty(String key, String defaultValue) {
        return environment.getProperty(prefix + key, defaultValue);
    }
}
